<template>
  <div>
    <el-button type="primary" @click="add">添加</el-button>
    <list-vue @init="getList"   :arr="arr" @willUpdate="willUpdate" :info="info"></list-vue>
    <form-vue :info="info" :arr="arr" @init="getList" ref="form"></form-vue>
  </div>
</template>

<script>
import listVue from "./components/list.vue";
import formVue from "./components/form.vue";
import {  reqmenulist} from "../../http/api";

export default {
  components: {
    listVue,formVue
  },
  methods: {
    add(){
        this.info.isshow = true;
        this.info.isAdd = true;
    },
    willUpdate(id){
        this.info.isshow = true;
        this.info.isAdd = false;
        this.$refs.form.getOne(id)
    },
    getList(){
         reqmenulist({istree:true}).then(res => {
        // console.log(res);
        this.arr = res.data.list ? res.data.list : [];
    })
    }
  },
  mounted() {
    this.getList()
  },
  data() {
    return {
        info: {
        isshow: false,
        isAdd: true,
      },
      arr: [
      ],
    };
  },
};
</script>

<style scoped>
.el-button {
  margin: 20px;
}
</style>